The -lscs# is a library initial routine. The -lscs1 only reads HIPS and FITS images. The -lscs2 can read one more type image RLE. The -lscs3 reads all of the supporing type images, except PICT & JPEG. The -lscs4 reads all of them except JPEG. The -lscs5 reads all. The -lscs6 reads all and writes some of the supporing types. The -lscs[1-4] only output HIPS and RLE images. For other output formats, see "man toany". U_IMAGE *img; /* union image structure defined in "imagedef.h" */ format_init(img, Init_TYPE, Middle_TYPE, Output_TYPE, char* name, char* version); int (*img->std_swif)(FI_LOAD_FILE, img, char* name, bool multi_frames / OsameI); int (*img->std_swif)(FI_RLOAD_BUF, img, char* buf, bool multi_frames / OsameI); int (*img->std_swif)(FI_ACCESS_ABS_FRAME, img, char* buf, int nth_frame); All 3 above return loading data size if successful, or EOF on failure. The FI_LOAD_FILE will check the buffer size (img->src). If it is not correct. std_swif will free the old one and allocate a new one. For FI_RLOAD_BUF and FI_ACCESS_ABS_FRAME, the buf argumant must be allocated and passed to std_swif. The multi_frame flag (for RLE) tells loading routine not to rewind or advance this file for any purpose since the rest frames will be loaded in order. Other multi-frame images, the control variable `img->load_all' controls loading process to load next N (= img->load_all) frames. N=0 & N=1 are same. The OsameI flag tells loading routine not to change the image format, such as 8-bit color to 24-bit, or 24-bit color to 8-bit transform. The char* name is the name of caller or any information that you want to pass to the function for tracing errors. bool (*img->std_swif)(FI_SAVE_FILE, img, char* buffer/bool map, int #th_frame/LKT* lkt); /* for HIPS | RLE */ bool (*img->std_swif)(FI_SAVE_FILE, img, char* buffer/bool map, int alpha / reverse); /* for Sun_Raster | TiFF */ If NULL buffer or no map, save img.src. Otherwise, save buffer or img.dest For saving multiple frame image, the control variable `img->save_all' functions as same as the `img->load_all' in saving control. When output Sun-Raster file, alpha flag generates alpha channel. Outputting TiFF image, reverse flag will swap RGB to BGR or another way around. bool (*img->std_swif)(FI_DESC_ETA, img, char* info, CER* cer); bool (*img->std_swif)(FI_INIT_NAME, img, char* name, 0); initial header with name string. above bool functions return 0 on successful, or -1 on failure. xel** (*img->std_swif)(FI_PNM_MAXVAL, img, &max_value); it returns PNM data buffer pointer and the max_value. bool (*img->header_handle)(HEADER_READ, img, 0, bool multi_frame, bool OsameI); bool (*img->header_handle)(HEADER_FREAD, img, FILE* fp, bool multi_frame, bool OsameI); For writing HIPS or FITS. bool (*img->header_handle)(HEADER_WRITE, img, int ac, char* av, bool update_header); bool (*img->header_handle)(HEADER_FWRITE, img, int ac, char* av, FILE* fp); The update_header is always true. bool (*img->header_handle)(ADD_DESC, img, char* info); bool (*img->header_handle)(HEADER_TRANSF, img, 0); make output same as input. bool (*img->header_handle)(HEADER_FROM, img, struct header*); bool (*img->header_handle)(HEADER_TO, img, bool initial_header); these header routines return 0 on successful, or EOF (-1) on failure. If struct header pointer is NULL in HEADER_FROM call, then internal header will be returned. Other functions: isColorImage(int CFM_format) this function returns color channels if CFM_format is a color format. Otherwise, it returns 0. For exampke: color_channels = isColorImage(img->in_color); To_8(U_IMAGE *img, cmap_t* rg_cmap[], bool quant, int n_colors) dither or quantize ( if quant != 0) a true color image to a pseudo color image. ras8_to_rle(byte *obp, byte *ibp, int width, U_IMAGE *img, cmap_t* cmap[3], int o_chans) any_color_to_rle(byte *obp, byte *ibp, U_IMAGE *img, int in_chans, bool revs) cell_to_line_color(byte *obp, byte *ibp, int width, int in_chans, byte* cmap[]) line_to_cell_color(char *obp, *rle, int width, int height) ilc_transfer(char *op, char *ip, int width, int in_chans, bool revs, int o_chans) These are color to different color image converters. Also, the color to gray-scale converters are available in colortog.c. rotate90(VType *ibuf, VType *obuf, int newr, int newc, int pix_size, int rflag) rotate an image count-clockwise 90 degrees (or clockwise 90 if rflag != 0) The 32-bit color image (CFM_ALPHA) can be directly rotated by set pix_size = 4. For other color images, please look at the torast.c, torle.c, and toicc.c.
input type output format (depends on img->mid_type) HIPS Standard 256 gray scale format (SGF) Standard 8-bit Color Format + color map (SCF) Interleave Cell (ILC) Separated Plane (SEPLANE) FITS SGF (img->mid_type == HIPS || !img->color_dpy) SCF (img->mid_type == RLE) RLE SCF InterLeaf in Line [scan line] format (ILL) SGF (!img->color_dpy, the followings are the same) GIF SCF (OsameI flag set) ILL (other color format) SGF SUN-RASTER SCF (8-bit color input & OsameI flag is set) ILL (other colors) SGF TIFF SCF (1 channel input) ILL (other input types, img->mid_type==RLE), ILC (img->mid_type == OTHER) SGF PNM SCF (if able to convert to 8-bit color), ILL (always), ILC (in saved data buffer, see color_ps.c) SGF ICC ILL (img->mid_type == RLE || == COLOR_PS) SEPLANE (img->color_dpy, otherwise) SGF (img->color_form == CFM_SGF) PICT SGF SEPLANE ILL (default) JPEG ILL (default) SGF (! img->color_dpy)
/* To_Others . C % % Copyright (c) 1991, Jin Guojun */ #include "header.def" #include "imagedef.h" U_IMAGE uimg; char usage[]= "to_others [-hips] [-rast] [-rle] [-color] in.any > out.other\n"; main(argc, argv) int argc; char* argv[]; { char info[128]; int i, mid_type, out_header=True, o_type=HIPS; /* initial input any type, and output OTHER type */ for (i=1; i < argc; i++) if (*argv[i] == '-') { if (strcmp(argv[i], "-rle") == 0) o_type = RLE; else if (strcmp(argv[i], "-rast") == 0) o_type = RAS; else if (strcmp(argv[i], "-color") == 0) uimg.color_dpy++; } else if ((in_fp=fopen(argv[i], "rb") == NULL) syserr("open input %s", argv[i]); uimg.color_dpy = -1; /* for color transfer. 0 for generating gray scale image. 1 for generating color image */ /* use RLE format for other conversions */ mid_type = o_type==HIPS ? HIPS : RLE; format_init(&uimg, IMAGE_INIT_TYPE, mid_type, o_type, *argv, "S20-1"); io_test(fileno(in_fp), usage_n_options(usage, i, argv[i])); if (in_header) if ((*uimg.header_handle)(HEADER_READ, &uimg, 0, 0, True) < 0) syserr("Unknown image type"); uimg.pxl_out = uimg.pxl_in; /* output size = input size, for HIPS */ /* example to add description */ sprintf(info, "%s: e%d*%d_%d_%d", i_name, enlg_row, enlg_cln, bgn_row,bgn_cln); (*uimg.header_handle)(ADD_DESC, &uimg, info); uimg.update_header = (*uimg.header_handle)(HEADER_TO, &uimg, 0); /* don't update again while HEADER_WRITE */ if (uimg.o_type == HIPS) /* HIPS is a single header type image */ if (out_header) (*uimg.header_handle)(HEADER_WRITE, &uimg, argc, argv, True); else (*uimg.header_handle)(HEADER_FWRITE, &uimg, argc, argv, stderr); for (f=0; f<uimg.frames; f++) (*uimg.std_swif)(FI_LOAD_FILE, &uimg, 0, 0), (*uimg.std_swif)(FI_SAVE_FILE, &uimg, 0, 0); exit(0); }